import type { LoginReq, LoginResp } from '~/api/common/model/login.ts'
import { MICRO_SERVICE_ADMIN } from '~/constants/service-constant.ts'

enum Api {
  DisplayCaptchaImage = '/admin/captcha/showCaptchaImage',
  Login = '/admin/login',
  Logout = '/admin/logout',
}

/**
 * 获取是否展示图形验证码
 */
export function displayCaptchaImageApi() {
  return useGet<boolean>(MICRO_SERVICE_ADMIN + Api.DisplayCaptchaImage, {}, {

  })
}

/**
 * 登录
 */
export function loginApi(params: LoginReq) {
  return usePost<LoginResp, LoginReq>(MICRO_SERVICE_ADMIN + Api.Login, params, {
    // 设置为false的时候不会携带token
    token: false,
    // 是否开启全局请求loading
    loading: true,
  })
}

/**
 * 注销
 */
export function logoutApi() {
  return useGet(MICRO_SERVICE_ADMIN + Api.Logout)
}
